package com.ruoyi.web.controller.system.statis.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.statis.domain.ServiceStatisEmployee;
import com.ruoyi.system.statis.service.IServiceStatisEmployeeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工统计Controller
 * 
 * @author Administrator
 * @date 2021-03-06
 */
@Controller
@RequestMapping("/statis/employee")
public class ServiceStatisEmployeeController extends BaseController
{
    private String prefix = "statis/employee";

    @Autowired
    private IServiceStatisEmployeeService serviceStatisEmployeeService;

    @RequiresPermissions("statis:employee:view")
    @GetMapping()
    public String employee()
    {
        return prefix + "/employee";
    }

    /**
     * 查询员工统计列表
     */
    @RequiresPermissions("statis:employee:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ServiceStatisEmployee serviceStatisEmployee)
    {
        startPage();
        List<ServiceStatisEmployee> list = serviceStatisEmployeeService.selectServiceStatisEmployeeList(serviceStatisEmployee);
        return getDataTable(list);
    }

    /**
     * 导出员工统计列表
     */
    @RequiresPermissions("statis:employee:export")
    @Log(title = "员工统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ServiceStatisEmployee serviceStatisEmployee)
    {
        List<ServiceStatisEmployee> list = serviceStatisEmployeeService.selectServiceStatisEmployeeList(serviceStatisEmployee);
        ExcelUtil<ServiceStatisEmployee> util = new ExcelUtil<ServiceStatisEmployee>(ServiceStatisEmployee.class);
        return util.exportExcel(list, "employee");
    }

    /**
     * 新增员工统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存员工统计
     */
    @RequiresPermissions("statis:employee:add")
    @Log(title = "员工统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ServiceStatisEmployee serviceStatisEmployee)
    {
        return toAjax(serviceStatisEmployeeService.insertServiceStatisEmployee(serviceStatisEmployee));
    }

    /**
     * 修改员工统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ServiceStatisEmployee serviceStatisEmployee = serviceStatisEmployeeService.selectServiceStatisEmployeeById(id);
        mmap.put("serviceStatisEmployee", serviceStatisEmployee);
        return prefix + "/edit";
    }

    /**
     * 修改保存员工统计
     */
    @RequiresPermissions("statis:employee:edit")
    @Log(title = "员工统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ServiceStatisEmployee serviceStatisEmployee)
    {
        return toAjax(serviceStatisEmployeeService.updateServiceStatisEmployee(serviceStatisEmployee));
    }

    /**
     * 删除员工统计
     */
    @RequiresPermissions("statis:employee:remove")
    @Log(title = "员工统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(serviceStatisEmployeeService.deleteServiceStatisEmployeeByIds(ids));
    }
}
